home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / misc / p96pcq.lha / Picasso96PCQ / Examples / OpenPIP.p < prev    next >
Encoding:
Text File  |  1997-07-18  |  3.8 KB  |  139 lines

  1. Program OpenPIP;
  2.  
  3. {
  4.     PCQ-Version des Picasso96-Demoprogrammes
  5.  
  6.     in Pascal übersetzt von Andreas Neumann
  7. }
  8.  
  9. { ***********************************************************************
  10.   * This is an example that shows how to open a p96 PIP Window
  11.   * to get input events and how to paint in that window.
  12.   *
  13.   *********************************************************************** }
  14.  
  15. {$I "Include:exec/memory.i" }
  16. {$I "Include:exec/libraries.i" }
  17. {$I "Include:dos/RDArgs.i" }
  18. {$I "Include:libraries/dosextens.i" }
  19. {$I "Include:graphics/graphics.i" }
  20. {$I "Include:graphics/pens.i" }
  21. {$I "Include:intuition/intuition.i" }
  22. {$I "Include:utils/stringlib.i" }
  23. {$I "Include:p96/Picasso96.i" }
  24.  
  25.  
  26. Const
  27.         WB          :   String = "Workbench";
  28.         gfxname     :   String = "graphics.library";
  29.         WDTitle     :   String = "Picasso96 API PIP Test";
  30.         template    :   String = "Width=W/N,Height=H/N,Pubscreen=PS/K";
  31.         vecarray    :   Array[0..2] of Address = (Nil, Nil, Nil);
  32.  
  33. Var
  34.         PubScreenName   :   Array [0..80] Of Char;
  35.         i,
  36.         height,
  37.         width           :   Integer;
  38.         wd              :   WindowPtr;
  39.         imsg            :   IntuiMessagePtr;
  40.         goahead         :   Boolean;
  41.         rp              :   RastPortPtr;
  42.         ptags           :   Array [0..32] Of TagItem;
  43.         x,
  44.         y               :   Short;
  45.         rda             :   RDArgsPtr;
  46.  
  47.  
  48. Begin
  49.  width:=256;
  50.  height:=256;
  51.  StrCpy (Adr(PubScreenName),WB);
  52.  
  53.  rda:=ReadArgs (template,Adr(vecarray),Nil);
  54.  If rda<>Nil Then
  55.  Begin
  56.   If vecarray[0]<>NIL then CopyMem(vecarray[0],adr(width),4);
  57.   If vecarray[1]<>NIL then CopyMem(vecarray[1],adr(height),4);
  58.   If vecarray[2]<>NIL then StrCpy(adr(PubScreenName),vecarray[2]);
  59.   FreeArgs(rda);
  60.  End;
  61.  
  62.  GfxBase:=OpenLibrary (gfxname,0);
  63.  If GfxBase<>Nil Then
  64.  Begin
  65.   P96Base:=OpenLibrary (P96Name,2);
  66.   If P96Base<>Nil Then
  67.   Begin
  68.    ptags[0].ti_Tag:=P96PIP_SourceFormat;
  69.    ptags[0].ti_Data:=RGBFB_R5G5B5;
  70.    ptags[1].ti_Tag:=P96PIP_SourceWidth;
  71.    ptags[1].ti_Data:=256;
  72.    ptags[2].ti_Tag:=P96PIP_SourceHeight;
  73.    ptags[2].ti_Data:=256;
  74.    ptags[3].ti_Tag:=WA_Title;
  75.    ptags[3].ti_Data:=Integer(WDTitle);
  76.    ptags[4].ti_Tag:=WA_Activate;
  77.    ptags[4].ti_Data:=Integer(TRUE);
  78.    ptags[5].ti_Tag:=WA_RMBTrap;
  79.    ptags[5].ti_Data:=Integer(TRUE);
  80.    ptags[6].ti_Tag:=WA_Width;
  81.    ptags[6].ti_Data:=Width;
  82.    ptags[7].ti_Tag:=WA_Height;
  83.    ptags[7].ti_Data:=Height;
  84.    ptags[8].ti_Tag:=WA_DragBar;
  85.    ptags[8].ti_Data:=Integer(TRUE);
  86.    ptags[9].ti_Tag:=WA_DepthGadget;
  87.    ptags[9].ti_Data:=Integer(TRUE);
  88.    ptags[10].ti_Tag:=WA_SimpleRefresh;
  89.    ptags[10].ti_Data:=Integer(TRUE);
  90.    ptags[11].ti_Tag:=WA_SizeGadget;
  91.    ptags[11].ti_Data:=Integer(TRUE);
  92.    ptags[12].ti_Tag:=WA_CloseGadget;
  93.    ptags[12].ti_Data:=Integer(TRUE);
  94.    ptags[13].ti_Tag:=WA_IDCMP;
  95.    ptags[13].ti_Data:=IDCMP_CLOSEWINDOW;
  96.    ptags[14].ti_Tag:=WA_PubScreenName;
  97.    ptags[14].ti_Data:=Integer(Adr(PubScreenName));
  98.    ptags[15].ti_Tag:=TAG_DONE;
  99.    wd:=p96PIP_OpenTagList (Adr(ptags));
  100.    If wd<>Nil Then
  101.    Begin
  102.     goahead:=True;
  103.     rp:=Nil;
  104.     ptags[0].ti_Tag:=P96PIP_SourceRPort;
  105.     ptags[0].ti_Data:=Integer(Adr(rp));
  106.     ptags[1].ti_Tag:=TAG_END;
  107.     p96PIP_GetTagList (wd,Adr(ptags));
  108.     If rp<>Nil Then
  109.     Begin
  110.      For y:=0 To (Height-1) Do
  111.       For x:=0 To (Width-1) Do
  112.        p96WritePixel (rp,x,y,(x*256+y)*256);
  113.     End
  114.     Else
  115.      Writeln ("No PIP rastport.");
  116.     While goahead Do
  117.     Begin
  118.      WaitPort (wd^.UserPort);
  119.      imsg:=p96PIP_GetIMsg (wd^.UserPort);
  120.      While imsg<>Nil Do
  121.      Begin
  122.       If imsg^.Class=IDCMP_CLOSEWINDOW Then
  123.        goahead:=False;
  124.       p96PIP_ReplyIMsg (imsg);
  125.       imsg:=p96PIP_GetIMsg (wd^.UserPort);
  126.      End;
  127.     End;
  128.     p96PIP_Close(wd);
  129.    End
  130.    Else
  131.     Writeln ("Unable to open PIP.");
  132.    CloseLibrary (P96Base);
  133.   End
  134.   Else
  135.    Writeln ("Unable to open Picasso96 library.");
  136.   CloseLibrary (GfxBase);
  137.  End;
  138. End.
  139.